import { ref } from "vue";
import { defineStore } from "pinia";
import { getSystyemModules } from "@/mctp-api/global";
import type { ModuleItem } from "@/mctp-api/global/index.d";

export const useGlobalModulesStore = defineStore("globalModules", () => {
  // 存储系统模块列表
  const systemModules = ref<ModuleItem[]>([]);

  /**
   * @description: 读取系统配置
   * @return {Promise<ModuleItem[]>} 返回模块列表
   */
  const loadSystemModules = async (): Promise<ModuleItem[]> => {
    const modules = await getSystyemModules();
    systemModules.value = modules?.data || [];
    return systemModules.value;
  };

  return {
    systemModules,
    loadSystemModules,
  };
});

